package com.edu.study.dao;

import com.edu.study.model.User;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;


/**
 * Created by liyih on 2017/4/8.
 */
@Repository
public interface UserDao extends PagingAndSortingRepository<User, Long> {

    User save(User user);

    User findOne(Long id);

    @Query("select u from User u where u.openid=?1")
    User findByOpenid(String openid);

    long count();

    @Modifying
    @Query("update User u set u.fans=?2 where u.openid=?1")
    int updateUserFans(String openid, int fans);
}
